home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / keyboard.swg / 0044_Another Readkey.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-08-27  |  1005 b   |  33 lines

  1. {
  2. SEAN PALMER
  3.  
  4. >I want to be able to transparently read a keypress.  In
  5. >other Words, I'd like to know what key is being pressed,
  6. >but allow the keypress to return to the keyboard buffer or
  7. >to be read by the Program that's reading it.  I'd like this
  8. >to Function as a TSR, and I need some way to Record the
  9. >keypresses.  This is a very complicated problem which I
  10. >have consulted many advanced Programmers With.  Please help
  11. >if you are able.  Thanks in advance!
  12.  
  13. It returns the Character part of the Char/scan code combo in the current
  14. head of the keyboard buffer queue in the bios data area.
  15. The scan code would be at the location $40:head+1.
  16.  
  17. It would probably be more efficient if you used $0:$41A instead of
  18. $40:$1A, but that might cause problems With protected mode.
  19. }
  20.  
  21. Var
  22.   head : Word Absolute $40 : $1A;
  23.   tail : Word Absolute $40 : $1C;
  24.  
  25. Function peekKey : Char;
  26. begin
  27.   if head = tail then
  28.     peekKey := #0
  29.   else
  30.     peekKey := Char(mem[$40 : head]);
  31. end;
  32.  
  33.